from pydantic import BaseModel
from typing import Optional
from datetime import datetime
from .user import UserResponse

class CommentBase(BaseModel):
    content: str

class CommentCreate(CommentBase):
    parent_id: Optional[int] = None

class CommentUpdate(CommentBase):
    pass

class CommentResponse(CommentBase):
    id: int
    is_approved: bool
    created_at: datetime
    updated_at: Optional[datetime] = None
    author_id: int
    post_id: str
    parent_id: Optional[int] = None
    
    # 作者信息
    author: Optional[UserResponse] = None
    
    class Config:
        from_attributes = True